' Program Name: PVMonitoring_2007-11-14.cr1 ' Program modified PVMonitoring_2007-10-29.cr1 ' edited public variable for moved sensors on mux 2, StationBattTemp moved to Set1 and the rest moved up ' changed to add east variation instead of subtract to get true. ' 6Nov2007 To maintain data, I kept the same program name and made a few repairs. AMcHugh ' the is the the current CCHRC PV monitoring program 'Declare Public Variables Public LoggerTemp_C, BattVolts_V, StationSPvolts_V Public RefSR_W_m2 Public StationID Public Therm_kOhm (66), Temp_C (66) Public SRArray_W_m2(4) public CompassOut as STRING * 35 Public CompassOutString As String * 30 Public Compass1ResString(3) 'as FLOAT ' (not as string) Public Compass2ResString(3) 'as FLOAT ' (not as string) Public Compass3ResString(3) 'as FLOAT ' (not as string) Public Compass4ResString(3) 'as FLOAT ' (not as string) Public AzimuthTrue(4) Alias Compass1ResString(1) = AzimuthMag1 Alias Compass1ResString(2) = Elevation1 Alias Compass1ResString(3) = Roll1 Alias Compass2ResString(1) = AzimuthMag2 Alias Compass2ResString(2) = Elevation2 Alias Compass2ResString(3) = Roll2 Alias Compass3ResString(1) = AzimuthMag3 Alias Compass3ResString(2) = Elevation3 Alias Compass3ResString(3) = Roll3 Alias Compass4ResString(1) = AzimuthMag4 Alias Compass4ResString(2) = Elevation4 Alias Compass4ResString(3) = Roll4 'Mux#1 Alias Temp_C (1)= BSPT1_3_1_C Alias Temp_C (2)= BSPT1_3_2_C Alias Temp_C (3)= BSPT1_3_3_C Alias Temp_C (4)= BSPT1_5_1_C Alias Temp_C (5)= BSPT1_5_2_C Alias Temp_C (6)= BSPT1_5_3_C Alias Temp_C (7)= BSPT1_8_1_C Alias Temp_C (8)= BSPT1_8_2_C Alias Temp_C (9)= BSPT1_8_3_C Alias Temp_C (10)= BSPT1_10_1_C Alias Temp_C (11)= BSPT1_10_2_C Alias Temp_C (12)= BSPT1_10_3_C Alias Temp_C (13)= BSPT2_4_1_C Alias Temp_C (14)= BSPT2_4_2_C Alias Temp_C (15)= BSPT2_4_3_C Alias Temp_C (16)= BSPT2_7_1_C Alias Temp_C (17)= BSPT2_7_2_C Alias Temp_C (18)= BSPT2_7_3_C Alias Temp_C (19)= BSPT2_10_1_C Alias Temp_C (20)= BSPT2_10_2_C Alias Temp_C (21)= BSPT2_10_3_C Alias Temp_C (22)= BSPT2_13_1_C Alias Temp_C (23)= BSPT2_13_2_C Alias Temp_C (24)= BSPT2_13_3_C Alias Temp_C (25)= BSPT3_4_1_C Alias Temp_C (26)= BSPT3_4_2_C Alias Temp_C (27)= BSPT3_4_3_C Alias Temp_C (28)= BSPT3_7_1_C Alias Temp_C (29)= BSPT3_7_2_C Alias Temp_C (30)= BSPT3_7_3_C Alias Temp_C (31)= BSPT3_10_1_C Alias Temp_C (32)= BSPT3_10_2_C Alias Temp_C (33)= BSPT3_10_3_C Alias Temp_C (34)= BSPT3_13_1_C Alias Temp_C (35)= BSPT3_13_2_C Alias Temp_C (36)= BSPT3_13_3_C Alias Temp_C (37)= BSPT4_1_1_C Alias Temp_C (38)= BSPT4_1_2_C Alias Temp_C (39)= BSPT4_1_3_C Alias Temp_C (40)= BSPT4_4_1_C Alias Temp_C (41)= BSPT4_4_2_C Alias Temp_C (42)= BSPT4_4_3_C Alias Temp_C (43)= BSPT4_6_1_C Alias Temp_C (44)= BSPT4_6_2_C Alias Temp_C (45)= BSPT4_6_3_C Alias Temp_C (46)= BSPT4_7_1_C Alias Temp_C (47)= BSPT4_7_2_C Alias Temp_C (48)= BSPT4_7_3_C ' Mux#2 Alias Temp_C (49) = StationBattTemp_C1 Alias Temp_C (50) = StationBattTemp_C2 Alias Temp_C (51) = StationBattTemp_C3 Alias Temp_C (52)= BSPT4_10_1_C Alias Temp_C (53)= BSPT4_10_2_C Alias Temp_C (54)= BSPT4_10_3_C Alias Temp_C (55)= BSPT4_11_1_C Alias Temp_C (56)= BSPT4_11_2_C Alias Temp_C (57)= BSPT4_11_3_C Alias Temp_C (58)= BSPT4_13_1_C Alias Temp_C (59)= BSPT4_13_2_C Alias Temp_C (60)= BSPT4_13_3_C Alias Temp_C (61)= BSPT4_16_1_C Alias Temp_C (62)= BSPT4_16_2_C Alias Temp_C (63)= BSPT4_16_3_C Alias Temp_C (64) = StationSPtemp_C1 Alias Temp_C (65) = StationSPtemp_C2 Alias Temp_C (66) = StationSPtemp_C3 ' Define Units Units LoggerTemp_C=Deg C Units BattVolts_V=Volts Units StationSPvolts_V=Volts Units RefSR_W_m2=W/m2 Units Temp_C(66)=DegC Units SRArray_W_m2()=W/m2 Dim i Dim j Dim D(96) Dim therm(96) 'Declare Constants ' Set Station Name as: CCHRC_1 Upstairs StationName (CCHRC_9) 'STATION ID Const ID = 22 'INSERT STATION ID HERE <---------- ' For YSI thermistors -- conversion of kOHM to deg C Const a = 0.0014654354 Const b = 0.0002386780 Const c = 0.0000001000 ' link to declination page http://www.ngdc.noaa.gov/seg/geomag/jsp/struts/calcDeclination Const declination=21.83 ' East, so we would add 21 deg 50 min or 21.83 degrees from the magnetic reading to get true. 'FIXED RESISTOR VALUE FOR GWS THERMISTOR CIRCUITS Const Rf_1 = 1.0 'INSERT FIXED RESISTOR #1 VALUE (kOHM) HERE <---------- 'Define Data Tables ' 255 data values DataTable(FifteenMinPVtemps, true, -1) DataInterval(0,15,Min,10) Sample(1, STATIONID, FP2) Sample (60,BSPT1_3_1_C,FP2) Average (60,BSPT1_3_1_C,FP2,False) Maximum (60,BSPT1_3_1_C,FP2,False,False) Minimum (60,BSPT1_3_1_C,FP2,False,False) Sample (3,StationSPtemp_C1,FP2) Average (3,StationSPtemp_C1,FP2,False) Maximum (3,StationSPtemp_C1,FP2,False,False) Minimum (3,StationSPtemp_C1,FP2,False,False) EndTable ' DataTable (FifteenMinSolarRad, true, -1) DataInterval (0,15, min, 10) Sample(1, STATIONID, FP2) Sample (4,SRArray_W_m2(),FP2) Average (4,SRArray_W_m2(),FP2,False) Maximum (4,SRArray_W_m2(),FP2,False,False) Minimum (4,SRArray_W_m2(),FP2,False,False) Sample (1,RefSR_W_m2,FP2) Average (1,RefSR_W_m2,FP2,False) Maximum (1,RefSR_W_m2,FP2,False,False) Minimum (1,RefSR_W_m2,FP2,False,False) EndTable ' DataTable (FifteenMinPanelAlign, true, -1) DataInterval(0,15,Min,10) Sample(1, STATIONID, FP2) Sample (2,Compass1ResString(),IEEE4) ' not as string Sample (2,Compass2ResString(),IEEE4) ' not as string Sample (2,Compass3ResString(),IEEE4) ' not as string Sample (2,Compass4ResString(),IEEE4) ' not as string Sample (4,AzimuthTrue(),FP2) StdDev (2,Compass1ResString(),FP2,False) StdDev (2,Compass2ResString(),FP2,False) StdDev (2,Compass3ResString(),FP2,False) StdDev (2,Compass4ResString(),FP2,False) StdDev (4,AzimuthTrue(),FP2,False) EndTable '255 data values DataTable(HourlyPVtemps, true, -1) DataInterval(0,60,Min,10) Sample(1, STATIONID, FP2) Sample (60,BSPT1_3_1_C,FP2) Average (60,BSPT1_3_1_C,FP2,False) Maximum (60,BSPT1_3_1_C,FP2,False,False) Minimum (60,BSPT1_3_1_C,FP2,False,False) Sample (3,StationSPtemp_C1,FP2) Average (3,StationSPtemp_C1,FP2,False) Maximum (3,StationSPtemp_C1,FP2,False,False) Minimum (3,StationSPtemp_C1,FP2,False,False) EndTable ' DataTable (HourlySolarRad, true, -1) DataInterval (0,60, min, 10) Sample(1, STATIONID, FP2) Sample (4,SRArray_W_m2(),FP2) Average (4,SRArray_W_m2(),FP2,False) Maximum (4,SRArray_W_m2(),FP2,False,False) Minimum (4,SRArray_W_m2(),FP2,False,False) Sample (1,RefSR_W_m2,FP2) Average (1,RefSR_W_m2,FP2,False) Maximum (1,RefSR_W_m2,FP2,False,False) Minimum (1,RefSR_W_m2,FP2,False,False) EndTable ' DataTable(HourlyDiag, true, -1) DataInterval(0,60,Min,10) Sample(1, STATIONID, FP2) Sample (1,LoggerTemp_C,FP2) Average (1,LoggerTemp_C,FP2,False) Sample (1,BattVolts_V,FP2) Average (1,BattVolts_V,FP2,False) Maximum (1,BattVolts_V,FP2,False,False) Minimum (1,BattVolts_V,FP2,False,False) Sample (3,StationBattTemp_C1,FP2) Average (3,StationBattTemp_C1),FP2,False) Maximum (3,StationBattTemp_C1,FP2,False,False) Minimum (3,StationBattTemp_C1,FP2,False,False) Sample (1,StationSPvolts_V,FP2) Average (1,StationSPvolts_V,FP2,False) EndTable ' DataTable(HourlyRaw1, true, -1) DataInterval(0,60,Min,10) Sample(1, STATIONID, FP2) Sample (66,Therm_kOhm(),FP2) Average (66,Therm_kOhm(),FP2,False) EndTable DataTable(HourlyRaw2, true, -1) DataInterval(0,60,min, 10) Sample(1, STATIONID, FP2) Maximum (66,Therm_kOhm(),FP2,False,False) Minimum (66,Therm_kOhm(),FP2,False,False) EndTable ' DataTable (HourlyPanelAlign, true, -1) DataInterval(0,60,Min,10) Sample(1, STATIONID, FP2) Sample (2,Compass1ResString(),IEEE4) ' not as string Sample (2,Compass2ResString(),IEEE4) ' not as string Sample (2,Compass3ResString(),IEEE4) ' not as string Sample (2,Compass4ResString(),IEEE4) ' not as string Sample (4,AzimuthTrue(),FP2) StdDev (2,Compass1ResString(),FP2,False) StdDev (2,Compass2ResString(),FP2,False) StdDev (2,Compass3ResString(),FP2,False) StdDev (2,Compass4ResString(),FP2,False) StdDev (4,AzimuthTrue(),FP2,False) EndTable ' DataTable(DailyPVarray, true, -1) DataInterval (0,1440, Min, 10) Sample(1, STATIONID, FP2) Average (60,BSPT1_3_1_C,FP2,False) Average (4,SRArray_W_m2(),FP2,False) Average (1,RefSR_W_m2,FP2,False) Average (3,StationSPtemp_C1,FP2,False) EndTable 'Main Program BeginProg Scan (5,Sec,0,0) PanelTemp (LoggerTemp_C,250) Battery (BattVolts_V) StationID = ID ' Measure Solar Panel Voltage VoltSe (StationSPvolts_V,1,mV2500,16,1,0,250,0.011,0) ' 1-minute measurement section '*************************************************************************** ' Measure each array's Azimuth and elevation every 10 minutes. '*************************************************************************** 'turn on compass/ li200x mux with C1 PortSet (1 ,1 ) If IfTime (0,1,Min) Then PulsePort (4, 10000) ' clock mux with C4 Delay (0,2,Sec) SerialOpen (Com4,19200,0,0,100) CompassOutString = "*Q"+CHR(13)+CHR(10) SerialOut (Com4,CompassOutString,"",0,0) SerialFlush (Com4) SerialIn (CompassOut,Com4,20,CHR(13),35) SplitStr (Compass1ResString(),CompassOut,",",3,0) PulsePort (4, 10000) Delay (0,2,Sec) SerialOpen (Com4,19200,0,0,100) CompassOutString = "*Q"+CHR(13)+CHR(10) SerialOut (Com4,CompassOutString,"",0,0) SerialFlush (Com4) SerialIn (CompassOut,Com4,20,CHR(13),35) SplitStr (Compass2ResString(),CompassOut,",",3,0) PulsePort (4, 10000) Delay (0,2,Sec) SerialOpen (Com4,19200,0,0,100) CompassOutString = "*Q"+CHR(13)+CHR(10) SerialOut (Com4,CompassOutString,"",0,0) SerialFlush (Com4) SerialIn (CompassOut,Com4,20,CHR(13),35) SplitStr (Compass3ResString(),CompassOut,",",3,0) PulsePort (4, 10000) Delay (0,2,Sec) SerialOpen (Com4,19200,0,0,100) CompassOutString = "*Q"+CHR(13)+CHR(10) SerialOut (Com4,CompassOutString,"",0,0) SerialFlush (Com4) SerialIn (CompassOut,Com4,20,CHR(13),35) SplitStr (Compass4ResString(),CompassOut,",",3,0) AzimuthTrue(1) = Compass1ResString(1) + declination AzimuthTrue(2) = Compass2ResString(1) + declination AzimuthTrue(3) = Compass3ResString(1) + declination AzimuthTrue(4) = Compass4ResString(1) + declination ' put the true Azimuth back within 0-360 if it goes over or under with the declination correction. For i = 1 To 4 If AzimuthTrue(i) < 0 Then AzimuthTrue(i) = AzimuthTrue(i) + 360 Next i ' subtract 45 degrees from the pitch readings to compenste for the pre offset Compass1ResString(2) = Compass1ResString(2) - 45 Compass2ResString(2) = Compass2ResString(2) - 45 Compass3ResString(2) = Compass3ResString(2) - 45 Compass4ResString(2) = Compass4ResString(2) - 45 'turn off compass, pitch and Elevation mux, to start counting at 1 when it is reset and clocked. PortSet (1,0) ' delay between reset low/hi Delay (0,20,mSec) '*************************************************************************** ' measure the solar radiation sensors on thier mux '*************************************************************************** ' I am sharing control port 1 as a Reset for both the HMR3300s and the LI200Xs. This can be done because the sensors are wired into ' unique logger channels ' turn on LI200X mux PortSet (1,1) ' switch to first channel PulsePort (4 ,10000) ' Measure Reflected Solar Radiation VoltDiff (RefSR_W_m2,1,mV7_5,1,True ,0,_60Hz,200,0) ' measure the next 4 in a loop I = 1 SubScan (0,Sec,4) PulsePort (4 ,10000) VoltDiff (SRArray_W_m2(I),1,mV7_5,1,True ,0,_60Hz,200,0) I = I + 1 NextSubScan 'turn off compass, pitch and Elevation mux, to start counting at 1 when it is reset and clocked. PortSet (1,0) '*************************************************************************** '' READ AM16/32 #1 MULTIPLEXER '' '*************************************************************************** 'READ 48 GWS THERMISTORS, CCHTH3_1 THROUGH CCHTH3_12, ' CCHTH4_1 THROUGH CCHTH5_3, ' CCHTH8_1 THROUGH CCHTH9_3, ' CCHTH34_1 THROUGH CCHTH35_3, ' CCHTH223_1 THROUGH CCHTH 228_3 PortSet (2 ,1 ) 'TURN ON AM16/32 #1 MULTIPLEXER, SET PORT 2 HIGH I = 1 'INITIALIZE INDEX INTERGER I TO ONE SubScan (0,Sec,16) 'SCAN LOOP -- 16 ITERATIONS PulsePort (4 ,10000) 'ADVANCE AM16/32 #1 GROUP BY 1, PULSE PORT 4 'MEASURE GWS THERMISTORS, (Voltage Ratio X = Rs/(Rs+Rf)) BrHalf (therm(I),1,mV2500,9,Vx2,1,2500,True ,0,_60Hz,1.0,0) I = I + 1 BrHalf (therm(I),1,mV2500,10,Vx2,1,2500,True ,0,_60Hz,1.0,0) I = I + 1 BrHalf (therm(I),1,mV2500,11,Vx2,1,2500,True ,0,_60Hz,1.0,0) I = I + 1 NextSubScan PortSet (2 ,0 ) 'TURN ONFFAM16/32 #1 MULTIPLEXER, SET PORT 2 LOW 'CONVERT MEASURED VOLTAGE RATIO TO RESISTANCE (kOHM) FOR 48 GWS THERMISTORS For I=1 To 48 Therm_kOhm(I) = Rf_1*therm(I)/(1-therm(I)) Next I 'CONVERT GWS THERMISTOR RESISTANCE TO deg C FOR 48 GWS THERMISTORS For I=1 To 48 D(I) = LN (1000*Therm_kOhm(I)) 'ln resistance (ohm) Temp_C(I) = (1/(a + b*D(I) + c*(D(I))^3)) - 273.15 'Steinhart & Hart Equation Next I '*************************************************************************** '' READ AM16/32 #2 MULTIPLEXER '' '*************************************************************************** 'READ 33 GWS THERMISTORS, CCHTH229_1 THROUGH CCHTH237_3, ' CCHTH242_1 THROUGH CCHTH243_3, PortSet (3,1 ) 'TURN ON AM16/32 #2 MULTIPLEXER, SET PORT 3 HIGH I = 49 'INITIALIZE INDEX INTERGER I TO 49 SubScan (0,Sec,16) 'SCAN LOOP -- 16 ITERATIONS PulsePort (4 ,10000) 'ADVANCE AM16/32 #1 GROUP BY 1, PULSE PORT 4 'MEASURE GWS THERMISTORS, (Voltage Ratio X = Rs/(Rs+Rf)) BrHalf (therm(I),1,mV2500,12,Vx3,1,2500,True ,0,_60Hz,1.0,0) I = I + 1 BrHalf (therm(I),1,mV2500,13,Vx3,1,2500,True ,0,_60Hz,1.0,0) I = I + 1 BrHalf (therm(I),1,mV2500,14,Vx3,1,2500,True ,0,_60Hz,1.0,0) I = I + 1 NextSubScan PortSet (3 ,0 ) 'TURN OFF AM16/32 #2 MULTIPLEXER, SET PORT 3 LOW ''' CONVERT MEASURED VOLTAGE RATIO TO RESISTANCE (kOHM) FOR 48 GWS THERMISTORS ''' For I=49 To 96 Therm_kOhm(I) = Rf_1*therm(I)/(1-therm(I)) Next I ''''' CONVERT GWS THERMISTOR RESISTANCE TO deg C FOR 48 GWS THERMISTORS ''''' For I=49 To 96 D(I) = LN (1000*Therm_kOhm(I)) 'ln resistance (ohm) Temp_C(I) = (1/(a + b*D(I) + c*(D(I))^3)) - 273.15 'Steinhart & Hart Equation Next I EndIf 'Enter other measurement instructions 'Call Output Tables 'Example: CallTable (HourlyDiag) CallTable (HourlyRaw1) CallTable (HourlyRaw2) CallTable (FifteenMinPanelAlign) CallTable (FifteenMinSolarRad) CallTable (FifteenMinPVtemps) CallTable (HourlyPVtemps) CallTable (HourlySolarRad) CallTable (HourlyPanelAlign) CallTable (DailyPVarray) NextScan EndProg